﻿@inherits Vowei.Web.G18nWebViewPage<IEnumerable<Vowei.Core.Models.Ticket>>
@using Vowei.Core.Models
@using Vowei.Web.Helpers
@using System.Web.Mvc.Html 

@if (Model.Count() > 0)
{
    <table id="@Vowei.Web.Models.WebConstants.TicketsTableId">
        <tr>
            <th>
                @T(t => t.First().Title)
            </th>
            <th>
                @T(t => t.OfType<Requirement>().First().BusinessValue)
            </th>
            <th>
                @T(t => t.First().AssignedTo)
            </th>
            <th>
                @T(t => t.OfType<Task>().First().StartDate)
            </th>
            <th>
                @T(t => t.OfType<Task>().First().DueDate)
            </th>
            <th class="row_pk">@T(t => t.First().ID)</th>
            <th class="row_pk">@T("类型")</th>
            <th class="row_pk">@T(t => t.First().BelongsToMilestone)</th>
        </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @item.Title
            </td>
            <td>
                @if (item is Requirement)
                {
                    var req = item as Requirement;
                    <span>@req.BusinessValue</span>
                }
            </td>
            <td>
                @item.AssignedTo
            </td>
            <td>
                @{
           DateTime? date = null;
           if (item is Task)
           {
               date = ((Task)item).StartDate;
           }
                }
                @T(date)
            </td>
            <td>
                @{
           if (item is Task)
           {
               date = ((Task)item).DueDate;
           }
                }
                @T(date)
            </td>
            <td class="row_pk">@item.ID</td>
            <td class="row_pk">
                @{
                          string typeName = null;
                          if (item is Requirement)
                          {
                              typeName = @T("需求");
                          }
                          else
                          {
                              typeName = @T("任务");
                          }
                }        
                @typeName        
            </td>
            <td class="row_pk">
                @item.BelongsToMilestoneId
            </td>
        </tr>
    }

    </table>
}
else
{
    <p>@T("没有任何任务信息")</p>
}

<p>
    <a href="/Ticket/ExportToExcel/?title=@Server.UrlEncode(ViewBag.Title)">@T("导出到Excel")</a>
</p>
